package com.majsubtense.core.achievements;

import com.majsubtense.main.ui.AchievementUI;

import java.util.ArrayList;
import java.util.List;

public class AchievementController {
    private static final List<Achievement> achievements = new ArrayList<>();
    private static AchievementUI ui;

    public static void initialize() {
        ui = new AchievementUI();
        ui.attach();

        achievements.add(new PressSettingButtonAchievement());
        achievements.add(new PressGameStartButtonAchievement());
        achievements.add(new PressResetButtonAchievement());
    }

    public static  <T extends Achievement> T getAchievement(AchievementType<T> achievementType) {
        for (Achievement achievement : achievements)
            if (achievementType.equals(achievement.getAchievementType()))
                // noinspection unchecked
                return (T) achievement;
        return null;
    }

    public static void showAchievementDialog(Achievement achievement) {
        ui.showAchievementDialog(achievement.getAchievementMessage());
    }
}
